package com.fdb.basic.framework.core.threadpool;

import java.util.Collection;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;

/**
 * 线程池信息
 * @author Cytus_
 * @since 2018-04-29 16:43:37
 * @version 1.0
 */
public interface ThreadPool {
	
	/**
	 * defautl the pool max number
	 */
	public final static int MAX_THREAD_NUM = 10;
	
	/**
	 * default the pool running name is "DEFAUTL"
	 */
	public final static String DEFAULT_RUNNING = "DEFAULT";

	/**
	 * add task for the pool queue
	 * @param task
	 */
	public void add(Callable<ExecuteRtnInfo> task) throws Exception ;
	
	/**
	 * add tasks for the pool queue
	 * @param tasks
	 */
	public void add(Collection<Callable<ExecuteRtnInfo>> tasks);
	
	/**
	 * the pool is running
	 * @return
	 */
	public boolean getRunning();
	
	/**
	 * start
	 */
	public void start();
	
	/**
	 * stop pool
	 */
	@Deprecated
	public void stop();
	
	/**
	 * set the thread pool run status
	 * @param isRunning
	 */
	public void setRunning(boolean isRunning);
	
	/**
	 * unblock live thread queue
	 */
	public void unblock();
	
	/**
	 * release finish queue task
	 * @param future
	 */
	void releaseFinishedThread(Future<ExecuteRtnInfo> future);
	
	/**
	 * the pool sync live max task number
	 * @return
	 */
	public Integer getMaxTaskNum();
	
	/**
	 * the pool sync live task number
	 * @return
	 */
	public Integer getLiveThreadNum();
	
	/**
	 * get the pool wait execute queue info
	 * @return
	 */
	public BlockingQueue<Callable<ExecuteRtnInfo>> getTaskQueue();
	
	/**
	 * get the pool wait execute finish queue info
	 * @return
	 */
	public BlockingQueue<Future<ExecuteRtnInfo>> getFinishQueue();
	
	/**
	 * set the pool name
	 * @param name
	 */
	void setPoolName(String name);
	
	/**
	 * destroy the pool
	 */
	void destroy();
	
}
